-
Notifications
You must be signed in to change notification settings - Fork 134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
⚗️[Logs] POC dependency injection #2520
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #2520 +/- ##
==========================================
- Coverage 93.22% 93.09% -0.13%
==========================================
Files 222 228 +6
Lines 6654 6736 +82
Branches 1460 1465 +5
==========================================
+ Hits 6203 6271 +68
- Misses 451 465 +14 ☔ View full report in Codecov by Sentry. |
7d502d0
to
820225a
Compare
if (canUseEventBridge()) { | ||
injector.override(startLogsSessionManager, startLogsSessionManagerStub) | ||
injector.override(startLogsBatch, startLogsBridge) | ||
} | ||
const pageExitObservable = createPageExitObservable(configuration) | ||
|
||
const session = | ||
configuration.sessionStoreStrategyType && !canUseEventBridge() && !willSyntheticsInjectRum() | ||
? startLogsSessionManager(configuration) | ||
: startLogsSessionManagerStub(configuration) | ||
|
||
const { telemetry, stop: stopLogsTelemetry } = startLogsTelemetry( | ||
configuration, | ||
reportError, | ||
pageExitObservable, | ||
session.expireObservable | ||
) | ||
cleanupTasks.push(() => stopLogsTelemetry()) | ||
telemetry.setContextProvider(() => ({ | ||
application: { | ||
id: getRUMInternalContext()?.application_id, | ||
}, | ||
session: { | ||
id: session.findTrackedSession()?.id, | ||
}, | ||
view: { | ||
id: (getRUMInternalContext()?.view as Context)?.id, | ||
}, | ||
action: { | ||
id: (getRUMInternalContext()?.user_action as Context)?.id, | ||
}, | ||
})) | ||
|
||
startNetworkErrorCollection(configuration, lifeCycle) | ||
startRuntimeErrorCollection(configuration, lifeCycle) | ||
startConsoleCollection(configuration, lifeCycle) | ||
startReportCollection(configuration, lifeCycle) | ||
const { handleLog } = startLoggerCollection(lifeCycle) | ||
|
||
startLogsAssembly(session, configuration, lifeCycle, buildCommonContext, reportError) | ||
|
||
if (!canUseEventBridge()) { | ||
const { stop: stopLogsBatch } = startLogsBatch( | ||
configuration, | ||
lifeCycle, | ||
reportError, | ||
pageExitObservable, | ||
session.expireObservable | ||
) | ||
cleanupTasks.push(() => stopLogsBatch()) | ||
} else { | ||
startLogsBridge(lifeCycle) | ||
if (!configuration.sessionStoreStrategyType || willSyntheticsInjectRum()) { | ||
injector.override(startLogsSessionManager, startLogsSessionManagerStub) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: those "override" in the wild could probably be moved in components, ex:
const startLogsTransport: Component<...> = (injector) => {
if (canUseEventBridge()) {
return injector.run(startLogsBridge)
} else {
return injector.run(startLogsBatch)
}
}
const injector: Injector = { | ||
run(component) { | ||
if (instances.has(component)) { | ||
throw new Error(`Component ${component.name} already started`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: This assertion and the following ones (in get
and override
) are not strictly needed, but helps to debug weird injection cases.
Motivation
Play with a dependency injection approach to see how it could look like
Changes
Testing
I have gone over the contributing documentation.